import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
import { FocusService } from './focus.service';
import { CreateFocusDto } from './dto/create-focus.dto';
import { UpdateFocusDto } from './dto/update-focus.dto';

@Controller('focus')
export class FocusController {
  constructor(private readonly focusService: FocusService) {}

  // 关注用户
  @Post('follow')
  follow(@Body() createFocusDto: CreateFocusDto) {
    return this.focusService.follow(createFocusDto);
  }

  // 取消关注
  @Post('unfollow')
  unfollow(@Body() body: { follower_id: string; following_id: string }) {
    return this.focusService.unfollow(body.follower_id, body.following_id);
  }

  // 查询用户的关注列表（用户关注了哪些人）
  @Post('following')
  getFollowingList(@Body() userid ) {
    return this.focusService.getFollowingList(userid);
  }

  // 查询用户的粉丝列表（哪些人关注了该用户）
  @Post('followers')
  getFollowersList(@Body() body: { userid: string }) {
    return this.focusService.getFollowersList(body.userid);
  }

  // 检查是否关注了某个用户
  @Post('isFollowing')
  isFollowing(@Body() follower_id: { follower_id: string; following_id: string }) {
    return this.focusService.isFollowing(follower_id.follower_id, follower_id.following_id);
  }

  // 获取关注统计
  @Post('stats')
  getFollowStats(@Body() body: { userid: string }) {
    return this.focusService.getFollowStats(body.userid);
  }

  // 切换关注状态
  @Post('toggle')
  toggleFollow(@Body() body: { follower_id: string; following_id: string }) {
    return this.focusService.toggleFollow(body.follower_id, body.following_id);
  }

  // 原有的方法保留但不使用
  @Post()
  create(@Body() createFocusDto: CreateFocusDto) {
    return this.focusService.create(createFocusDto);
  }

  @Get()
  findAll() {
    return this.focusService.findAll();
  }

  @Get(':id')
  findOne(@Param('id') id: string) {
    return this.focusService.findOne(+id);
  }

  @Patch(':id')
  update(@Param('id') id: string, @Body() updateFocusDto: UpdateFocusDto) {
    return this.focusService.update(+id, updateFocusDto);
  }

  @Delete(':id')
  remove(@Param('id') id: string) {
    return this.focusService.remove(+id);
  }
}
